<template>
  <el-form
    :inline="true"
    size="mini"
    :model="formInline"
    class="demo-form-inline"
  >
    <el-row v-for="(item, index) in searchForm" :key="index">
      <!-- 输入框 -->
      <el-form-item :label="item.label" v-if="item.type === 'input'">
        <el-input
          v-model="formInline[item.prop]"
          :placeholder="item.placeholder"
        ></el-input>
      </el-form-item>
      <!-- 下拉框 -->
      <el-form-item :label="item.label" v-else-if="item.type === 'select'">
        <el-select
          v-model="formInline[item.prop]"
          :placeholder="item.placeholder"
        >
          <el-option
            :label="option.label"
            :value="option.value"
            v-for="option in item.options"
            :key="option.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <!-- 日期选择器 -->
      <el-form-item :label="item.label" v-else-if="item.type === 'dateTime'">
        <el-date-picker
          v-model="formInline[item.prop]"
          type="datetimerange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        >
        </el-date-picker>
      </el-form-item>
      <!-- 联级选择器 -->
      <el-form-item :label="item.label" v-else-if="item.type === 'Cascader'">
        <el-cascader
          v-model="formInline[item.prop]"
          :options="item.options"
        ></el-cascader>
      </el-form-item>
      <!-- tag标签 -->
    </el-row>
    <el-form-item>
      <el-button type="primary" @click="onSearch" icon="el-icon-search"
        >查询</el-button
      >
      <el-button @click="onReset" icon="el-icon-refresh">重置</el-button>
    </el-form-item>
  </el-form>
</template>
  <script>
export default {
  props: {
    searchForm: {
      type: Array,
      default: () => {
        return [];
      },
    },
    getTableData: {
      type: Function,
    },
    pagination:{
      type:Object
    }
  },
  data() {
    return {
      formInline: {
      },
    };
  },
  methods: {
    onSearch() {
      this.getTableData && this.getTableData(this.pagination);
    },
    onReset() {
      this.formInline = {};
      this.getTableData && this.getTableData({size:10,current:1,total:0});
    },
  },
};
</script>
<style lang="scss" scoped>
.demo-form-inline {
  .el-row {
    display: inline-block;
  }
}
</style>